
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       sensor_imu_qmi8658.h
  * @author     baiyang
  * @date       2022-8-3
  ******************************************************************************
  */

#pragma once

#ifdef __cplusplus
extern "C"{
#endif

/*----------------------------------include-----------------------------------*/
#include "sensor_imu.h"
#include "sensor_imu_backend.h"

#include <common/time/gp_time.h>
#include <common/gp_rotations.h>
#include <device_manager/dev_mgr.h>
#include <common/gp_math/gp_mathlib.h>
/*-----------------------------------macro------------------------------------*/

/*----------------------------------typedef-----------------------------------*/
typedef struct sensor_imu_qmi8658* sensor_imu_qmi8658_t;
typedef struct qmi8658_fifo_accgyr* qmi8658_fifo_accgyr_t;
typedef struct qmi8658_fifo_accgyrmag* qmi8658_fifo_accgyrmag_t;

#pragma pack(1)
struct qmi8658_fifo_accgyr {
    uint16_t accel[3];
    uint16_t gyro[3];
};

struct qmi8658_fifo_accgyrmag {
    uint16_t accel[3];
    uint16_t gyro[3];
    uint16_t mag[3];
};
#pragma pack()

struct sensor_imu_qmi8658 {
    sensor_imu_backend backend;

    gp_device_t _dev;

    uint8_t _accel_instance;
    uint8_t _gyro_instance;

    enum RotationEnum _rotation;
    uint8_t _temperature_counter;

    float _accel_scale;
    float _gyro_scale;
};

/*----------------------------------variable----------------------------------*/

/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/
sensor_imu_backend * sensor_imu_qmi8658_probe(gp_device_t dev, enum RotationEnum rotation);
/*------------------------------------test------------------------------------*/

#ifdef __cplusplus
}
#endif



